using System;
using System.Collections.Generic;
using System.Text;

namespace SBPweb.Logging
{
    /// <summary>
    /// This class provides region based implicit category set definition by using instances of it in conjunction with using/> keyword.
    /// </summary>
    public class ImplicitCategory : IDisposable
    {
        private ICollection<String> mImplicitCategories;

        /// <summary>
        /// Defines a new implicit category.
        /// </summary>
        /// <param name="ImplicitCategory">Keyword to define.</param>
        public ImplicitCategory(String ImplicitCategory)
        {
            mImplicitCategories = new String[] { ImplicitCategory };

            LogManager.AddImplicitCategories(mImplicitCategories);
        }

        /// <summary>
        /// Defines a new set of implicit categories.
        /// </summary>
        /// <param name="ImplicitCategories">Set of keywords to define.</param>
        /// <exception cref="System.ArgumentNullException">The "ImplicitCategories" param was null.</exception>
        public ImplicitCategory(ICollection<String> ImplicitCategories)
        {
            if (ImplicitCategories == null)
                throw new ArgumentNullException("ImplicitCategories");

            mImplicitCategories = ImplicitCategories;

            LogManager.AddImplicitCategories(mImplicitCategories);
        }

        #region IDisposable Members

        /// <summary>
        /// Disposes a set of implicit categories.
        /// </summary>
        public void Dispose()
        {
            LogManager.RemoveImplicitCategories(mImplicitCategories);
        }

        #endregion
    }
}
